#!/usr/bin/env python3
# _*_ coding:utf-8 _*_

from Arc.utils.pagination import Pagination


def getpage(request, all_queryset, per_page=10, pager_page_count=7):
    all_count = all_queryset.count()
    query_params = request.GET.copy()
    query_params._mutable = True
    pager = Pagination(
        current_page=request.GET.get('page'),
        all_count=all_count,
        base_url=request.path_info,
        query_params=query_params,
        per_page=per_page,
        pager_page_count=pager_page_count,
    )
    data_list = all_queryset[pager.start:pager.end]
    return [pager, data_list]
